﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mmoss.orm;
using mmoss.configuration;
namespace mmoss.application
{
    public partial class frmChooseLocation : Form
    {


        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
                return myCp;
            }
        } 

        

        public Location SelectedLocation { get; set; }
        public frmChooseLocation()
        {
            InitializeComponent();
            this.Load += new EventHandler(frmChooseLocation_Load);
        }

        void frmChooseLocation_Load(object sender, EventArgs e)
        {
            //set menu options
            //set the grow locations
            List<Location> l_locations = Default.CurrentUser.UserPermissionsXrefs.Select(p => p.Location).Distinct().ToList();
            cboLocationSelect.DataSource = l_locations;
            cboLocationSelect.DisplayMember = "locationName";
            cboLocationSelect.ValueMember = "Id";
        }

        private void btnSetLocation_Click(object sender, EventArgs e)
        {
            SelectedLocation = (Location) cboLocationSelect.SelectedItem;
            this.Close();
        }
    }
}
